package com.ruoyi.project.module.maxObject.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.maxObject.domain.MaxObject;
import com.ruoyi.project.module.maxObject.service.IMaxObjectService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 业务对象配置 信息操作处理
 * 
 * @author ruoyi
 * @date 2021-02-16
 */
@Controller
@RequestMapping("/module/maxObject")
public class MaxObjectController extends BaseController
{
    private String prefix = "module/maxObject";
	
	@Autowired
	private IMaxObjectService maxObjectService;
	
	@RequiresPermissions("module:maxObject:view")
	@GetMapping()
	public String maxObject()
	{
	    return prefix + "/maxObject";
	}
	
	/**
	 * 查询业务对象配置列表
	 */
	@RequiresPermissions("module:maxObject:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(MaxObject maxObject)
	{
		startPage();
        List<MaxObject> list = maxObjectService.selectMaxObjectList(maxObject);
		return getDataTable(list);
	}
	
	/**
	 * 新增业务对象配置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存业务对象配置
	 */
	@RequiresPermissions("module:maxObject:add")
	@Log(title = "业务对象配置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(MaxObject maxObject)
	{		
		return toAjax(maxObjectService.insertMaxObject(maxObject));
	}

	/**
	 * 修改业务对象配置
	 */
	@GetMapping("/edit/{maxObjectId}")
	public String edit(@PathVariable("maxObjectId") Long maxObjectId, ModelMap mmap)
	{
		MaxObject maxObject = maxObjectService.selectMaxObjectById(maxObjectId);
		mmap.put("maxObject", maxObject);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存业务对象配置
	 */
	@RequiresPermissions("module:maxObject:edit")
	@Log(title = "业务对象配置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(MaxObject maxObject)
	{		
		return toAjax(maxObjectService.updateMaxObject(maxObject));
	}
	
	/**
	 * 删除业务对象配置
	 */
	@RequiresPermissions("module:maxObject:remove")
	@Log(title = "业务对象配置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(maxObjectService.deleteMaxObjectByIds(ids));
	}
	
}
